/*
 * @(#)IHEConfigTestProducer.java
 * Date 2013-11-04
 * Version 1.0
 * Author Jim Horner
 * Copyright (c)2012
 */


package us.hornerscorners.lamppost.atna.client;

import java.io.InputStream;

import javax.enterprise.inject.Alternative;
import javax.enterprise.inject.Produces;

import us.hornerscorners.lamppost.ihecommon.config.AtnaConfig;
import us.hornerscorners.lamppost.ihecommon.config.IHEConfig;

import us.hornerscorners.lamppost.ihecommon.inject.IHEConfigProducer;


/**
 * Class description
 *
 *
 * @version        v1.0, 2013-11-04
 * @author         Jim Horner    
 */
@Alternative
public class IHEConfigTestProducer {

    /**
     * Method description
     *
     *
     * @return
     */
    @Produces
    public IHEConfig produce() {

        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        InputStream is = cl.getResourceAsStream("config/META-INF/IHEConfig.yml");

        if (is == null) {

            throw new IllegalStateException("Missing config/META-INF/IHEConfig.yml");
        }

        IHEConfig config = IHEConfigProducer.readConfig(is);

        AtnaConfig atnaConfig = config.getAtnaConfig();

        atnaConfig.setKeyStore("../../../zSetup/Keystores/MIR2012-14-2/keystore.jks");
        atnaConfig.setTrustStore("../../../zSetup/Keystores/MIR2012-14-2/truststore.jks");

        return config;
    }
}
